var FG;
if (!FG)
    FG = {};


FG.Pager = function(opts) {
    var this_ = this;

    this.$el = $(opts.target);

    this.layers = {};
    this.currentLayerName = null;

    this.addLayer = function(layerName, layer) {
        var $layer = !!layer ? $(layer) : $('<div>');
        $layer.addClass('page_layer');
        $layer.attr('name', layerName);
        
        this.layers[layerName] = $layer;
        this.$el.append($layer);
        return $layer;
    };

    this.getLayer = function(layerName) {
        if (!layerName) {
            layerName = this.currentLayerName;
        }
        if (!layerName) {
            return;
        }
        return this.layers[layerName];
    };

    this.delLayer = function(layerName) {
        if (!layerName) {
            layerName = this.currentLayerName;
        }
        if (!layerName) {
            return;
        }
        if (_.has(this.layers, layerName)) {
            this.$el.remove('[name="' + layerName + '"]');
            delete this.layers[layerName]
        }
        return this;
    };

    this.toggleLayer = function(layerName, opts) {
        // TODO
        return this;
    };
};